import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button } from '@tarojs/components'
import './doctorstatus.css'
import { AtInput, AtForm, AtList, AtListItem, AtImagePicker, AtButton, AtIcon, AtRadio, AtTag } from 'taro-ui'
import reactMixin from 'react-mixin';
import myJs from './doctorstatusJs.js'
import app from '../../../../main.js'
import { doc } from 'nerv-utils';

export default class DoctorStatus extends Component {
  config = {
    navigationBarTitleText: '医生认证'
  }

  constructor() {
    super(...arguments);
    this.state = {
      doctor: {},
    }
  }

  init() { 
    
  }

  goCert() {
    app.navigateTo('/pages/center/pages/doctorcertified/doctorcertified');
  }

  check() {
    var me = this;
    app.get("web/doctor/get", {}, function (res) {
      app.current = res.data.result
      if (app.isEmpty(app.current)) {
        app.current = {};
      }
      var auth_status = app.current.auth_status;
      if (app.isEmpty(auth_status)) {
        auth_status = '未认证';
      }
      let userInfo = app.current
      console.log('决定去哪里', app.current)

      if (app.isEmpty(userInfo.head_image) || app.isEmpty(userInfo.nickname) || app.isEmpty(userInfo.phone)) {
        //没登录的跳转去登录提示页面
        app.redirectTo('/pages/doctorpages/firstEntry/firstEntry');
      } else if (auth_status == '未认证') { //跳转去填写资料
        app.redirectTo('/pages/center/pages/doctorcertified/doctorcertified');
      } else if (auth_status == '申请中' || auth_status == '审核不通过') {
        //无需跳转
      } else {
        app.redirectTo('/pages/doctorpages/homepage/homepage');
      }


      me.setState({
        info: app.current
      });
    });
  }



  render() {
    return (
      <View className='box'>
        {
          app.current.auth_status == '审核不通过' 
        ?<View>
          <View className='center'><Image style='width:200rpx;height:200rpx;' src={app.imageUri + 'img/jujue.png'}></Image></View>
          <View className='center bolder'>认证失败</View>
          
          {
            app.current.audit_msg
                  ? <View className='center bold msg'>{app.current.audit_msg}</View>
                  : <View className='center bold msg'>您提交的认证材料未通过审核,请重新填写资料后提交审核</View>
          }
          <View className='center'><AtButton type='primary' onClick={this.goCert} >修改认证资料</AtButton></View>
        </View>
        : <View>
          <View className='center'><Image style='width:200rpx;height:200rpx;' src={app.imageUri + 'img/shenhe.png'}></Image></View>
          <View className='center bolder'>正在审核中</View>
              <View className='center bold msg'>认证资料已经提交成功，请耐心等待后台审核</View>
              
            </View>
        }
      </View>
    )
  }
}
reactMixin.onClass(DoctorStatus, myJs);
